class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-06-15",
      revision: "29e275db9480cbfd66e6f69690ba893f20754749"
  version "2022-06-15"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "c7c74e35987bad22227f9aecf3f61a005ed2366680c567039c993fe508485402"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "692d03f9666cea5dbe5f5d7736e0ea8d56ba002a53ba28daf54e223943bd75a6"
    sha256 cellar: :any_skip_relocation, monterey:       "0f0010ad43fbd812d74be37cd96a0eeab87e5d227ba6c184a2b50d1b0ed29681"
    sha256 cellar: :any_skip_relocation, big_sur:        "758485e79b8a2693d816db1ebc014ed8e8fe4a2fac5296aae7128f93f5f055f9"
    sha256 cellar: :any_skip_relocation, catalina:       "5e2d5ddb237527cba7c45e973e273051d7f5b4085b3192d387a4c2d764e3256b"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "2809bc9d9c814f4dfc0193a4ded2fd71323bb80ac11ebbbe4563e2e4f65a00ff"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
